package com.jstorm.count.controller.common;

import com.jstorm.count.dto.CommonExecution;
import com.jstorm.count.pojo.Result;
import com.jstorm.count.service.commonroad.CommonroadService;
import com.jstorm.count.service.lineReconnaissance.LineReconnaossanceService;
import com.jstorm.count.service.linkroad.LinkroadService;
import com.jstorm.count.service.network.NetworkService;
import com.jstorm.count.service.signal.SignalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @ProjectName: springboot-mybatis
 * @Package: com.jstorm.count.controller
 * @ClassName: TotalController
 * @Description: 总数统计
 * @Author: Mr_hu
 * @CreateDate: 2019/1/2 12:25
 * ***********************************************************
 * @UpdateUser: Mr_hu
 * @UpdateDate: 2019/1/2 12:25
 * @UpdateRemark: The modified content
 * @Version: 1.0
 * ***********************************************************
 * Copyright: Copyright (c) 2019
 **/
@Controller
@RequestMapping("/total")
public class TotalController {

    /*** 链路层特征采集*/
    @Autowired
    private LinkroadService linkroadService;

    /*** ATM信令采集 */
    @Autowired
    private SignalService signalService;

    /*** 共路信令特征采集*/
    @Autowired
    private CommonroadService commonroadService;

    /** * 线路侦察数据特征采集 */
    @Autowired
    private LineReconnaossanceService lineReconnaossanceService;

    /*** 网络协议*/
    @Autowired
    private NetworkService networkService;



    @RequestMapping("/agreement")
    @ResponseBody
    public Result Total(){
        List<Map<String, Object>> listTotal=new ArrayList();

        CommonExecution linkroadList= linkroadService.selectTotal();
        linkroadList.getList().forEach(lineroad->listTotal.add(lineroad));

        List<Map<String, Object>> signalList = signalService.selectTotal();
        signalList.forEach(signal->listTotal.add(signal));

        CommonExecution commonroadList = commonroadService.selectTotal();
        commonroadList.getList().forEach(commonroad->listTotal.add(commonroad));


        CommonExecution lineReconnaossance = lineReconnaossanceService.selectTotal();
        lineReconnaossance.getList().forEach(line->listTotal.add(line));

        CommonExecution networkList = networkService.selectTotal();
        networkList.getList().forEach(network->listTotal.add(network));


        try {
            return Result.isOk().data(listTotal);
        } catch (Exception e) {
            return Result.isFail(e);
        }
    }

}
